package com.yzzrjy.old;

import com.yzzrjy.util.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "TestServlet", value = "/testServlet")
public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int lastUid = 10020000;
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());
        long oldTime = System.currentTimeMillis();
        for(int i = 0; i < 20000; i++){
            lastUid++;
            try {
                queryRunner.update("insert into user_info(uid,nickname) values(?,?)",lastUid, "小玫瑰");
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
        long time = System.currentTimeMillis() - oldTime;
        System.out.println("user time:"+time);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
